/**
 * 
 */
package stationGUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 * @author Owner
 *
 */
public class ChatScreen extends JPanel implements ActionListener {
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  
  
  JTextField message = new JTextField("hello world");
  JTextArea text = new JTextArea();
  
  
  /**
   * 
   */
  public ChatScreen() {
    super(new BorderLayout());
    setBorder(BorderFactory.createCompoundBorder(BorderFactory.
        createTitledBorder(BorderFactory.createLineBorder(Color.BLACK,1),
        "Chat With Neighbors:"),BorderFactory.createEmptyBorder(0,5,5,5)));
    add(message,BorderLayout.SOUTH);
    message.addActionListener(this);
    add(text,BorderLayout.CENTER);
    
  }

  public void actionPerformed(ActionEvent evt) {
    String t = message.getText();
    text.append("\nStation 1: "+t);
    message.selectAll();

    //Make sure the new text is visible, even if there
    //was a selection in the text area.
    text.setCaretPosition(text.getDocument().getLength());
}

  
  
  /**
   * @param arg0
   */
  public ChatScreen(LayoutManager arg0) {
    super(arg0);
    // TODO Auto-generated constructor stub
  }

  /**
   * @param arg0
   */
  public ChatScreen(boolean arg0) {
    super(arg0);
    // TODO Auto-generated constructor stub
  }

  /**
   * @param arg0
   * @param arg1
   */
  public ChatScreen(LayoutManager arg0, boolean arg1) {
    super(arg0, arg1);
    // TODO Auto-generated constructor stub
  }

}
